package com.song.invoicing.controller;

import com.song.invoicing.pojo.Result;
import com.song.invoicing.pojo.dto.ProductQueryDTO;
import com.song.invoicing.pojo.dto.PurchaseQueryDTO;
import com.song.invoicing.service.ProductService;
import com.song.invoicing.service.PurchaseRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/product")
@RequiredArgsConstructor
public class ProductController {

     private final ProductService productService;
    @GetMapping("/getProducts")
    public Result<Map<String,Object> > getProducts(ProductQueryDTO productQueryDTO) {
        return Result.success(productService.getProducts(productQueryDTO));
    }
    @PutMapping("/updatePrice")
    public Result updatePrice( @RequestParam("productId") Integer  productId, @RequestParam("price") Double price) {
        productService.updatePrice(productId,price);
        return Result.success();
    }
}
